package com.fs.jzzn.pojo;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import com.fs.base.pojo.PEntity;
import com.fs.base.utils.ExcelUtils;

/**
 * @author TiddlerCJ
 * @desc 施工信息实体
 */
@Entity
@Table(name="p_information")
@Data@EqualsAndHashCode(callSuper=false)
public class Information extends PEntity{
	private String workUnit;			//施工单位
	private String workManager;			//施工负责人
	private String workManagerPhone;	//施工负责人电话
	
	private String startDate;				//开工时间
	private String endDate;					//完工时间
	private String checkDate;				//验收时间
	private String supervisorUnit;		//监理单位
	private String supervisorName;		//监理人
	private String supervisorPhone;		//监理电话
	private String workDays;				//工期（天数）
	private String workDesc;				//工作量描述
	private String opticCableCores;		//光缆芯数（芯数）
	private String opticCableLength;	//光缆米数（上报距离）
	private String subcontract;			//分包合同号
	private String dataManager;			//资料员
	private String pNo;						//立项编号

	private String together;				//是否合放
	private Integer ztLen = 0;			//本地网长度---中铁长度
	private Integer dlLen = 0;			//电力长度
	private String department;		//工程归属项目部
	
	public static List<Information> excelDataFormat(List<List<String>> data) {
		List<Information> list = new ArrayList<Information>();
		for(List<String> rowData: data){
			list.add(excelData2Bean(rowData));
		}
		//删除标题行
		//if(list.size()>0) { list.remove(0); }
		return list;
	}
	//"[\"项目编号\",\"分包合同\",\"施工单位\",\"施工负责人\",\"施工负责人电话\",\"开工时间\",\"完工时间\",\"
	//"验收时间\",\"监理单位\",\"监理人\",\"监理电话\",\"工期（天数）\",\"工作量描述\",\"实际芯数\",\"实际米数\",\"资料员\",\"是否合放\",\"本地网长度\",\"电力长度\"]";
	private static Information excelData2Bean(List<String> row){
		row = ExcelUtils.dataLenFomart(row, 19);
		Information inf = new Information();
		inf.setPNo(row.get(0));//项目编号
		inf.setSubcontract(row.get(1));//分包合同
		inf.setWorkUnit(row.get(2));//施工单位
		inf.setWorkManager(row.get(3));//施工负责人
		inf.setWorkManagerPhone(row.get(4));//施工负责人电话
		inf.setStartDate(row.get(5));//开工时间
		inf.setEndDate(row.get(6));//完工时间
		inf.setCheckDate(row.get(7));//验收时间
		inf.setSupervisorUnit(row.get(8));//监理单位
		inf.setSupervisorName(row.get(9));//监理人
		inf.setSupervisorPhone(row.get(10));//监理电话
		inf.setWorkDays(row.get(11));//工期
		inf.setWorkDesc(row.get(12));//工作量描述
		inf.setOpticCableCores(row.get(13));//实际芯数
		inf.setOpticCableLength(row.get(14));//实际米数
		inf.setDataManager(row.get(15));//资料员
		inf.setTogether(row.get(16));//是否合放
		try {
			Integer ztLen = Integer.parseInt(row.get(17));
			inf.setZtLen(ztLen);//本地网长度
		} catch (Exception e) {
			System.err.println("本地网长度格式有误："+row.get(17) );
		}
		try {
			Integer dlLen = Integer.parseInt(row.get(18));
			inf.setDlLen(dlLen);//电力长度
		} catch (Exception e) {
			System.err.println("电力长度格式有误："+row.get(18) );
		}
		return inf;
	}
}
